﻿var featurePlaceHolder = "spEditorFeatureImagePlaceHolder";
var featureIcon = "SPEditor/images/featureIcon.png";

function EnsureTrailingSlash(param) {
    var result = param;
    if(param.charAt(param.length-1) != '/') {
        result = param + "/";
    }
    return result;
}
function FindImages() {
    var images = document.getElementsByTagName("img");
    for (var i = 0; i < images.length; i++) {
        var source = images[i].src;
        if (source.indexOf(featurePlaceHolder) != -1) {
            var newSource = source.replace(source, EnsureTrailingSlash(_spPageContextInfo.siteServerRelativeUrl) + featureIcon);
            images[i].src = newSource;
        }
    }
}

_spBodyOnLoadFunctionNames.push("FindImages");